package net.lab1024.sa.admin.module.business.erp.controller;

import net.lab1024.sa.admin.module.business.erp.domain.entity.ApprovordEntity;
import net.lab1024.sa.admin.module.business.erp.domain.form.add.ApprovordAddForm;
import net.lab1024.sa.admin.module.business.erp.domain.form.query.ApprovordQueryForm;
import net.lab1024.sa.admin.module.business.erp.domain.form.update.ApprovordUpdateForm;
import net.lab1024.sa.admin.module.business.erp.domain.vo.ApprovordVO;
import net.lab1024.sa.admin.module.business.erp.service.ApprovordService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 审批主表 Controller
 *
 * @Author AKITA
 * @Date 2025-04-23 14:10:37
 * @Copyright AKITA
 */

@RestController
@Tag(name = "审批主表")
public class ApprovordController {

    @Resource
    private ApprovordService approvordService;

    @Operation(summary = "分页查询 @author AKITA")
    @PostMapping("/approvord/queryPage")
    public ResponseDTO<PageResult<ApprovordVO>> queryPage(@RequestBody @Valid ApprovordQueryForm queryForm) {
        return ResponseDTO.ok(approvordService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author AKITA")
    @PostMapping("/approvord/add")

    public ResponseDTO<Long> add(@RequestBody @Valid ApprovordAddForm addForm) {
        return approvordService.add(addForm);
    }

    @Operation(summary = "更新 @author AKITA")
    @PostMapping("/approvord/update")

    public ResponseDTO<String> update(@RequestBody @Valid ApprovordUpdateForm updateForm) {
        return approvordService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author AKITA")
    @PostMapping("/approvord/batchDelete")

    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return approvordService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author AKITA")
    @GetMapping("/approvord/delete/{docEntry}")

    public ResponseDTO<String> batchDelete(@PathVariable Long docEntry) {
        return approvordService.delete(docEntry);
    }


    @Operation(summary = "分页查询 @author AKITA")
    @PostMapping("/approvord/info")
    public ResponseDTO<List<ApprovordEntity>> info(@RequestBody ApprovordQueryForm queryForm) {
        return ResponseDTO.ok(approvordService.info(queryForm));
    }

}
